package a;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int cishu=3;
        while (true) {
            System.out.println("请输入数字：");
            int a = sc.nextInt();
            cishu--;
            if (guess(a)) {
                break;
            }
            if(cishu==0){
                System.out.println("失败");
                break;
            }
            System.out.println("你还有"+cishu+"次机会");
            System.out.println("是否继续游戏？Y/N");
            String b=sc.next();

            if(!"Y".equalsIgnoreCase(b)) {
                System.out.println("游戏结束！");
                break;
            }
        }
    }

    static boolean guess(int a) {
        int i = 6;
        if (a < i) {
            System.out.println("猜小了");
            return false;
        } else if (a == i) {
            System.out.println("猜对了");
            return true;
        } else {
            System.out.println("猜大了");
            return false;
        }
    }
}
